/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package portelogiche;

/**
 *
 * @author danielederuschi
 */
public class Port {
        
        public String portType, input1,input2, output;
        public boolean error= false;
        public int line, col;
    public Port(String type, String i1, String i2, String o1, int l, int c){
        
        this.portType = type;
        this.input1 = i1;
        this.input2 = i2;
        this.output = o1;
        this.line = l;
        this.col = c;


        
    }
    
    public String geti1(){
        String string = this.input1;
        return string;
    }
        
     public String geti2(){
        String string = this.input2;
        return string;
    }
     
         public String geto1(){
        String string = this.output;
        return string;
    }
    public Boolean CheckEquals(){
        
        if(input1==null) input1="";
        if(input2==null) input2="";
        if(output==null) output="";
        
        Boolean equalExist = null;
        // Verifica se almeno un nome delle porte input ha lo stesso nome della porta di output
        if((!output.trim().equals("#")&&input1.trim().equals(output.trim())) || (!output.trim().equals("#")&&input2.trim().equals(output.trim()))){
            equalExist = true;
        }
        else{
            equalExist = false;
        }
        return equalExist;
        
       
    }
    
    
    @Override
    public String toString(){
        String string;
        if(this.portType.equals("NOT")){
        string = this.portType +"("+this.input1+","+this.output+") at "+this.line+":"+this.col;
        }
        else{
        string = this.portType +"("+this.input1+","+this.input2+","+this.output+") at "+this.line+":"+this.col;
        }
        return string;
    }
    
    

}
